package com.elective.courseselect.controller;

import com.elective.courseselect.entity.CourseCharacterEntity;
import com.elective.courseselect.service.CourseCharacterService;
import com.elective.courseselect.utils.PageUtils;
import com.elective.courseselect.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.Map;
/**
 * 课程标签
 *
 * @author lee
 * @email 943204006@qq.ccom
 * @date 2021-09-04 19:23:06
 */
@RestController
@RequestMapping("courseselect/coursecharacter")
public class CourseCharacterController {
    @Autowired
    private CourseCharacterService courseCharacterService;

    /**
     * 列表
     */
    @GetMapping("/list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = courseCharacterService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @GetMapping("/info/{id}")
    public R info(@PathVariable("id") Integer id){
		CourseCharacterEntity courseCharacter = courseCharacterService.getById(id);

        return R.ok().put("courseCharacter", courseCharacter);
    }

    /**
     * 保存
     */
    @PostMapping("/save")
    public R save(@RequestBody CourseCharacterEntity courseCharacter){
		courseCharacterService.save(courseCharacter);

        return R.ok();
    }

    /**
     * 修改
     */
    @PostMapping("/update")
    public R update(@RequestBody CourseCharacterEntity courseCharacter){
		courseCharacterService.updateById(courseCharacter);
        return R.ok();
    }

    /**
     * 课程标签接口添加
     */
    @PostMapping("/addCourseCharacters")
    public R addCourseCharacters(@RequestBody Map<String,Object> params) throws Exception{
        return courseCharacterService.addCourseCharacters(params);
    }

    /**
     * 课程标签接口删除
     */
    @DeleteMapping("/delCourseCharacters")
    public R delCourseCharacters(@RequestBody Map<String,Object> params) throws Exception{
        return courseCharacterService.delCourseCharacters(params);
    }


    /**
     * 课程标签接口修改
     */
    @PostMapping("/updateCourseCharacters")
    public R updateCourseCharacters(@RequestBody Map<String,Object> params) throws Exception{
        return courseCharacterService.updateCourseCharacters(params);
    }


    /**
     * 删除
     */
    @DeleteMapping("/delete")
    public R delete(@RequestBody Integer[] ids){
        courseCharacterService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }



}
